# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class JT_8801:
    result = []
    analysisDescription = ["通道ID:","拍摄命令:","拍照间隔/录像时间:","保存标志:","分辨率:","图像/视频质量:","亮度:","对比度:","饱和度:","色度:"]
    analysis8801Length = [1,2,2,1,1,1,1,1,1,1]
    def LogicAisle(self,protocolStr,header):
        count = 0
        s =""
        for i in range(len(self.analysisDescription)):
            if i==0:
                    s = protocolStr[count:count+(self.analysis8801Length[i] * 2)]
                    header.append(self.analysisDescription[i] + s +"\n");
                    count = count + self.analysis8801Length[i] * 2;
            elif i == 1:
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                if s == "0000":
                    header.append(self.analysisDescription[i] + s + " 停止拍摄" + "\n")
                elif s == "ffff":
                    header.append(self.analysisDescription[i] + s + " 录像" + "\n")
                else:
                    s = int(s,16)
                    header.append(self.analysisDescription[i] + "拍摄张数:"+str(s) + "\n")
                count = count + self.analysis8801Length[i] * 2
            if i==3:
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                if s == "01":
                    header.append(self.analysisDescription[i] + s + " 保存" + "\n")
                elif s == "00":
                    header.append(self.analysisDescription[i] + s + " 实时上传" + "\n")
                count = count + self.analysis8801Length[i] * 2
            if i==4:
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                if s == "01":
                    header.append(self.analysisDescription[i]  + " 320*240" + "\n")
                elif s == "02":
                    header.append(self.analysisDescription[i]  + " 640*480" + "\n")
                elif s == "03":
                    header.append(self.analysisDescription[i] + " 800*600" + "\n")
                elif s == "04":
                    header.append(self.analysisDescription[i] + " 1024*768" + "\n")
                elif s == "05":
                    header.append(self.analysisDescription[i] + " 176*144;[Qcif]" + "\n")
                elif s == "06":
                    header.append(self.analysisDescription[i] + " 352*288;[Cif]" + "\n")
                elif s == "07":
                    header.append(self.analysisDescription[i] + " 704*288;[HALF D1]" + "\n")
                elif s == "08":
                    header.append(self.analysisDescription[i] + " 704*576;[D1]" + "\n")
                count = count + self.analysis8801Length[i] * 2
            if ( i == 6 or i == 7 or i==8 or i==9 ):
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                s = int(s,16)
                header.append(self.analysisDescription[i] + str(s) + "\n")
                count = count + self.analysis8801Length[i] * 2
            if i==2:
                s=""
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                s = int(s,16)
                if s == 0 :
                     header.append(self.analysisDescription[i] + str(s) + "表示按最小间隔拍照或一直录像" + "\n")
                else:
                    header.append(self.analysisDescription[i] + str(s) + "秒" + "\n")
                count = count + self.analysis8801Length[i] * 2
            if i==5:
                s = protocolStr[count:count + (self.analysis8801Length[i] * 2)]
                s = int(s, 16)
                header.append(self.analysisDescription[i] + str(s) + "( 1代表质量损失最小，10表示压缩比最大)" + "\n")
                count = count + self.analysis8801Length[i] * 2
        self.result = header     
